#ifndef _PARTHUS_SYS_HAL_TYPES_H
#define _PARTHUS_SYS_HAL_TYPES_H

/******************************************************************************
 * MODULE NAME:    sys_hal_types.h
 * PROJECT CODE:   BlueStream
 * DESCRIPTION:    Basic platform specific type definitions
 * AUTHOR:         John Sheehy
 * DATE:           08 March 2001
 *
 * SOURCE CONTROL: $Id: sys_hal_types.h,v 1.4 2008/11/08 07:30:07 tianwq Exp $
 *
 * LICENSE:
 *     This source code is copyright (c) 2001-2004 Ceva Inc.
 *     All rights reserved.
 *
 * REVISION HISTORY:
 *    08 March 2001   - Initially added by js
 *
 *
 * NOTES TO USERS:
 ******************************************************************************/


/*
 * Unsigned types
 */

typedef unsigned char u_int8;         /* unsigned integer,  8 bits long */
typedef unsigned short u_int16;  /* unsigned integer, 16 bits long */
typedef unsigned int u_int32;         /* unsigned integer, 32 bits long */

/*
 * Signed types
 */

typedef signed char s_int8;
typedef signed short s_int16;
typedef signed long s_int32;


/*
 * Natural size of integers on processor
 * Uses: 1. for printf  format control and parameter compatability!
 *       2. for defining bit-fields (non-portable!)
 *       3. for efficient use of local variables (avoids masking)
 */

#ifdef SOLARIS
#include <sys/types.h>
#else
typedef unsigned int  u_int;          /* natural unsigned integer on processor */
#endif
typedef unsigned long int u_intL;     /* natural long unsigned integer on processor */

typedef struct s_u_int64
{
    u_int32 low ;      /* low 32 bits of a 64 bit value */
    u_int32 high;      /* high 32 bits of a 64 bit value */
} t_u_int64;

/*
    These are #defined to the smallest way to write/read u_intXX to/from a buffer on the platform
    The UINT8 version is included for completeness, and probably won't/shouldn't be used....     -MM
*/
#ifndef BT_WRITE_LE_UINT8
#define BT_WRITE_LE_UINT8(ptr,val)  (((*((u_int8 *)(ptr)))=(val)))
#define BT_WRITE_LE_UINT16(ptr,val) (((*((u_int8 *)(ptr)))=((u_int8)(val))),((*((u_int8 *)((ptr)+1)))=((u_int8)((val)>>8))))
#define BT_WRITE_LE_UINT24(ptr,val) (((*((u_int8 *)(ptr)))=((u_int8)(val))),((*((u_int8 *)((ptr)+1)))=((u_int8)((val)>>8))),((*((u_int8 *)((ptr)+2)))=((u_int8)((val)>>16))))
#define BT_WRITE_LE_UINT32(ptr,val) (((*((u_int8 *)(ptr)))=((u_int8)(val))),((*((u_int8 *)((ptr)+1)))=((u_int8)((val)>>8))),((*((u_int8 *)((ptr)+2)))=((u_int8)((val)>>16))),((*((u_int8 *)((ptr)+3)))=((u_int8)((val)>>24))))

#define BT_READ_LE_UINT8(ptr)       ((*((u_int8 *)(ptr))))
#define BT_READ_LE_UINT16(ptr)      ((*((u_int8 *)(ptr)))|((*((u_int8 *)((ptr)+1)))<<8))
#define BT_READ_LE_UINT24(ptr)      ((*((u_int8 *)(ptr)))|((*((u_int8 *)((ptr)+1)))<<8)|((*((u_int8 *)((ptr)+2)))<<16))
#define BT_READ_LE_UINT32(ptr)      ((*((u_int8 *)(ptr)))|((*((u_int8 *)((ptr)+1)))<<8)|((*((u_int8 *)((ptr)+2)))<<16)|((*((u_int8 *)((ptr)+3)))<<24))
#endif

#endif /* _PARTHUS_SYS_HAL_TYPES_H */


